home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / perl5 / User::pwent.z / User::pwent
Encoding:
Text File  |  1998-10-30  |  2.9 KB  |  133 lines

  1.  
  2.  
  3.  
  4. UUUUsssseeeerrrr::::::::ppppwwwweeeennnntttt((((3333))))                                                  UUUUsssseeeerrrr::::::::ppppwwwweeeennnntttt((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      User::pwent - by-name interface to Perl's built-in getpw*() functions
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.       use User::pwent;
  13.       $pw = getpwnam('daemon') or die "No daemon user";
  14.       if ( $pw->uid == 1 && $pw->dir =~ m#^/(bin|tmp)?$# ) {
  15.           print "gid 1 on root dir";
  16.       }
  17.  
  18.       use User::pwent qw(:FIELDS);
  19.       getpwnam('daemon') or die "No daemon user";
  20.       if ( $pw_uid == 1 && $pw_dir =~ m#^/(bin|tmp)?$# ) {
  21.           print "gid 1 on root dir";
  22.       }
  23.  
  24.       $pw = getpw($whoever);
  25.  
  26.  
  27. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  28.      This module's default exports override the core _g_e_t_p_w_e_n_t(), _g_e_t_p_w_u_i_d(),
  29.      and _g_e_t_p_w_n_a_m() functions, replacing them with versions that return
  30.      "User::pwent" objects.  This object has methods that return the similarly
  31.      named structure field name from the C's passwd structure from _p_w_d._h;
  32.      namely name, passwd, uid, gid, quota, comment, gecos, dir, and shell.
  33.  
  34.      You may also import all the structure fields directly into your namespace
  35.      as regular variables using the :FIELDS import tag.  (Note that this still
  36.      overrides your core functions.)  Access these fields as variables named
  37.      with a preceding pw_ in front their method names.  Thus, $passwd_obj-
  38.      >_s_h_e_l_l() corresponds to $pw_shell if you import the fields.
  39.  
  40.      The _g_e_t_p_w() funtion is a simple front-end that forwards a numeric
  41.      argument to _g_e_t_p_w_u_i_d() and the rest to _g_e_t_p_w_n_a_m().
  42.  
  43.      To access this functionality without the core overrides, pass the use an
  44.      empty import list, and then access function functions with their full
  45.      qualified names.  On the other hand, the built-ins are still available
  46.      via the CORE:: pseudo-package.
  47.  
  48. NNNNOOOOTTTTEEEE
  49.      While this class is currently implemented using the Class::Struct module
  50.      to build a struct-like class, you shouldn't rely upon this.
  51.  
  52. AAAAUUUUTTTTHHHHOOOORRRR
  53.      Tom Christiansen
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. UUUUsssseeeerrrr::::::::ppppwwwweeeennnntttt((((3333))))                                                  UUUUsssseeeerrrr::::::::ppppwwwweeeennnntttt((((3333))))
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.                                                                         PPPPaaaaggggeeee 2222
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.